package com.gw.yunke.web;

import com.gw.yunke.utils.VideoUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;

@RestController
public class HomeController {

    @RequestMapping(value = "/home",method = RequestMethod.GET)
    public String sayHello(Model model, HttpServletRequest request){

//        try {
//            VideoUtil.captureImage("video\\test.mp4","test.jpg");
//        } catch (IOException e) {
//            e.printStackTrace();
//            return "fail";
//        }
        System.out.println("==="+request.getServletContext());
        String path = request.getSession().getServletContext().getRealPath("video/");
        System.out.println("---"+path);
        //File file = new File("")
        model.addAttribute("url",path+"test.mp4");
        return "home2";
    }
    @RequestMapping(value = "/test",method = RequestMethod.GET)
    public String test(){
        return "okok";
    }
}
